package com.zt.location.modules.base.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zt.location.common.utils.PageUtils;
import com.zt.location.common.utils.Query;
import com.zt.location.common.utils.R;
import com.zt.location.modules.base.entity.RealTimeEntity;
import com.zt.location.modules.base.service.RealTimeService;




/**
 * 
 * 
 * @author admin
 * @email obj_admin@163.com
 * @date 2019-06-02 19:21:27
 */
@RestController
@RequestMapping("/base/realtime")
public class RealTimeController {
    @Autowired
    private RealTimeService realTimeService;

    /**
     * 列表
     */
    @RequestMapping("/qlist") 
	public R qlist(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<RealTimeEntity> realTimeList = realTimeService.queryList(query);
        return R.ok().put("realtimelist", realTimeList);
    }

    
    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("base:realtime:list")
	public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<RealTimeEntity> realTimeList = realTimeService.queryList(query);
        int total = realTimeService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(realTimeList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{readerId}")
    @RequiresPermissions("base:realtime:info")
    public R info(@PathVariable("readerId") String readerId){
		RealTimeEntity realTime = realTimeService.queryObject(readerId); 
        return R.ok().put("realTime", realTime);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("base:realtime:save")
    public R save(@RequestBody RealTimeEntity realTime){
			realTimeService.save(realTime);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("base:realtime:update")
    public R update(@RequestBody RealTimeEntity realTime){
			realTimeService.update(realTime);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/updateWeb")
    public R updateWeb(@RequestBody RealTimeEntity realTime){
			realTimeService.updateWebSpeed(realTime.getReaderId());

        return R.ok();
    }
    
    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("base:realtime:delete")
    public R delete(@RequestBody String[] readerIds){
			realTimeService.deleteBatch(readerIds);

        return R.ok();
    }
	
}
